<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$router->get('/', function () use ($router) {
    $router->get('demo', function () {});
});
$router->post('login', 'CommonController@login');
$router->post('download', 'CommonController@download'); //下载图片demo
$router->get('demo', 'CommonController@download');

$router->post('upload', 'UploadController@upload'); //单个上传文件
$router->post('uploads', 'UploadController@uploads'); //批量上传文件



$router->group(['middleware' => 'adminOuth'], function () use ($router) {

    $router->post('loginOut', 'CommonController@loginOut');
    $router->post('getUserInfo', 'CommonController@getUserInfo'); //获取后台用户信息
    $router->post('article/lists', 'ArticleController@lists'); //文章列表
    $router->post('article/add', 'ArticleController@add'); //文章新增


    // 商品管理
    $router->group(['prefix' => 'product'], function ($router) {

        $router->post('category/select', 'ProductCategoryController@getCategorySelect'); //获取所有商品分类

        $router->post('category/list', 'ProductCategoryController@list'); //商品分类列表
        $router->post('category/add', 'ProductCategoryController@add'); //商品分类添加
        $router->post('category/del', 'ProductCategoryController@del'); //商品分类删除
        $router->post('category/show', 'ProductCategoryController@show'); //商品分类查看
        $router->post('category/save', 'ProductCategoryController@save'); //商品分类保存

        $router->post('list', 'ProductController@list'); //商品列表
        $router->post('add', 'ProductController@add'); //添加商品
        $router->post('del', 'ProductController@del'); //商品删除
        $router->post('show', 'ProductController@show'); //商品查看
        $router->post('save', 'ProductController@save'); //商品保存
    });


    //权限管理
    $router->group(['prefix' => 'auth'], function ($router) {
        //添加用户
        $router->post('user/list', 'UserController@list');
        $router->post('user/add', 'UserController@add');
        $router->post('user/edit', 'UserController@edit');
        $router->post('user/update', 'UserController@update');
        $router->post('user/delete', 'UserController@delete');
        $router->post('user/userRoleList', 'UserController@userRoleList'); //用户获取所属角色列表
        $router->post('user/userRoleUpdate', 'UserController@userRoleUpdate'); //用户更新所属角色
        //添加角色
        $router->post('role/list', 'RoleController@list');
        $router->post('role/add', 'RoleController@add');
        $router->post('role/edit', 'RoleController@edit');
        $router->post('role/update', 'RoleController@update');
        $router->post('role/delete', 'RoleController@delete');
        //添加权限
        $router->post('permission/listTree', 'PermissionController@listTree');
        $router->post('permission/list', 'PermissionController@list');
        $router->post('permission/add', 'PermissionController@add');
        $router->post('permission/edit', 'PermissionController@edit');
        $router->post('permission/update', 'PermissionController@update');
        $router->post('permission/delete', 'PermissionController@delete');
        $router->post('permission/getFirst', 'PermissionController@getFirst');

        //分配权限
        $router->post('assign/save', 'AssignController@save');
        $router->post('assign/list', 'AssignController@list');





        $router->post('role/getMenuByRole', 'RoleController@getMenuByRole'); //获取角色的所有权限
        $router->post('role/saveRoleMenu', 'RoleController@saveRoleMenu'); //保存角色权限

    });
});
